package com.talos.ums.dal.mysql.user;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.user.vo.UmsUserPageReqVO;
import com.talos.ums.dal.dataobject.user.UmsUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsUserMapper extends BaseMapperX<UmsUserDO> {

    default PageResult<UmsUserDO> selectPage(UmsUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsUserDO>()
                .likeIfPresent(UmsUserDO::getUserName, reqVO.getUserName())
                .eqIfPresent(UmsUserDO::getPassword, reqVO.getPassword())
                .likeIfPresent(UmsUserDO::getNickName, reqVO.getNickName())
                .eqIfPresent(UmsUserDO::getPhone, reqVO.getPhone())
                .eqIfPresent(UmsUserDO::getMailAddress, reqVO.getMailAddress())
                .eqIfPresent(UmsUserDO::getGender, reqVO.getGender())
                .eqIfPresent(UmsUserDO::getHeadImgUrl, reqVO.getHeadImgUrl())
                .eqIfPresent(UmsUserDO::getUserType, reqVO.getUserType())
                .betweenIfPresent(UmsUserDO::getExpirationDate, reqVO.getExpirationDate())
                .eqIfPresent(UmsUserDO::getAuthorize, reqVO.getAuthorize())
                .betweenIfPresent(UmsUserDO::getPasswordExpirationDate, reqVO.getPasswordExpirationDate())
                .betweenIfPresent(UmsUserDO::getLockDate, reqVO.getLockDate())
                .eqIfPresent(UmsUserDO::getLoginTimes, reqVO.getLoginTimes())
                .eqIfPresent(UmsUserDO::getNewAccountFlag, reqVO.getNewAccountFlag())
                .eqIfPresent(UmsUserDO::getRemark, reqVO.getRemark())
                .eqIfPresent(UmsUserDO::getActiveFlag, reqVO.getActiveFlag())
                .eqIfPresent(UmsUserDO::getLanguage, reqVO.getLanguage())
                .betweenIfPresent(UmsUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsUserDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsUserDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsUserDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsUserDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsUserDO::getModifierId, reqVO.getModifierId())
                .eqIfPresent(UmsUserDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsUserDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsUserDO::getPassUid, reqVO.getPassUid())
                .eqIfPresent(UmsUserDO::getNeedModifyPassword, reqVO.getNeedModifyPassword())
                .eqIfPresent(UmsUserDO::getRepeatUserId, reqVO.getRepeatUserId())
                .eqIfPresent(UmsUserDO::getCompanyCode, reqVO.getCompanyCode())
                .eqIfPresent(UmsUserDO::getJobNumber, reqVO.getJobNumber())
                .eqIfPresent(UmsUserDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(UmsUserDO::getAllRole, reqVO.getAllRole())
                .eqIfPresent(UmsUserDO::getAllWarehouse, reqVO.getAllWarehouse())
                .eqIfPresent(UmsUserDO::getAllCompany, reqVO.getAllCompany())
                .eqIfPresent(UmsUserDO::getAllOrganization, reqVO.getAllOrganization())
                .eqIfPresent(UmsUserDO::getToAdmin, reqVO.getToAdmin())
                .eqIfPresent(UmsUserDO::getAllStation, reqVO.getAllStation())
                .eqIfPresent(UmsUserDO::getSource, reqVO.getSource())
                .eqIfPresent(UmsUserDO::getSourceDesc, reqVO.getSourceDesc())
                .eqIfPresent(UmsUserDO::getAllCarrier, reqVO.getAllCarrier())
                .eqIfPresent(UmsUserDO::getAllCustomer, reqVO.getAllCustomer())
                .eqIfPresent(UmsUserDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsUserDO::getId));
    }

}
